package com.sihai.core.support;

import org.hibernate.ScrollableResults;


/**
 * <code>ScrollableResultsTotalCountGetter</code> 使用 {@link org.hibernate.ScrollableResults} 获得总记录数
 */
public class ScrollableResultsTotalCountGetter implements TotalcountGetter {

    private ScrollableResults scrollableResults;

    public ScrollableResultsTotalCountGetter(ScrollableResults scrollableResults) {
        this.scrollableResults = scrollableResults;
    }

    @Override
    public int count() {
        scrollableResults.last();
        return scrollableResults.getRowNumber() + 1;
    }
}
